package com.example.lawyer.request;

import android.view.textclassifier.TextLinks;

import java.io.IOException;

import okhttp3.MediaType;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;

/***
 * 统一OKHttp请求
 */
public class RequestTool
{





    public String HttpPost(String url,String data)
    {
        String bodys = null;
        try {
            OkHttpClient client = new OkHttpClient();
            RequestBody requestBody = RequestBody.create(MediaType.parse("application/json; charset=utf-8"), data);
            Request builder = new Request.Builder().url(url).post(requestBody).build();
            Response response = client.newCall(builder).execute();
            bodys = response.body().string();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return bodys;
    }

}
